<template>
   <div>
    <MyHeader title="购物车案例"></MyHeader>
    <div class="main">
      <MyGoods :goodsList="goodsList"  ></MyGoods>
    </div>
    <MyFooter :goodsList="goodsList" @changeAll="changeAllFn"></MyFooter>
  </div>
</template>

<script>
import axios from "axios"
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },
  data(){
    return{
      goodsList:[]
    }
  },
  async created() {
     const {data} = await axios.get('https://www.escook.cn/api/cart')
      console.log(data.list)
      this.goodsList = data.list
    },
    methods:{
     changeAllFn(val) {
   this.goodsList.forEach((v)=>{
        v.goods_state =val
      })
     }
    }
  }


</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>